Mathematics, Digital Signal Processing, and Optimization (namespace Math)


Assessment: It dinamically computes: the minimum, the maximum, the mean and the variance
Assessment()
double getMaximum()
double getMean()
double getMinimum()
double getVariance()
void add(double value)
void reset()
~ Assessment()

AutomaticGainControl: It implements an Automatic Gain Control
AutomaticGainControl& operator =(const AutomaticGainControl& init)
AutomaticGainControl()
AutomaticGainControl(const AutomaticGainControl& init)
double GetAttackSpeed()
Low compression: 5 db/sec, Medium compression: 10 db/sec, High compression: 20 db/sec
double GetReleaseSpeed()
Low compression: 2 db/sec, Medium compression: 10 db/sec, High compression: 20 db/sec
int ComputeMaximum(int in_ch1, int in_ch2)
It returns the maximum value computed by using a time window
int GetBitsResolution()
8, 16, 24
int GetBufferLen()
int GetMaxValue()
It returns 127, 32767 or 8388607 depending on the bits resolution
int GetSamplesPerSec()
22050, 44100, 48000, 96000, ...
void ComputeOutput(double in_ch1, double in_ch2, double& out_ch1, double& out_ch2)
It returns the respective output sample for the stereo input For a mono signal, set in_ch2 = 0
void ComputeOutput(int in_ch1, int in_ch2, int& out_ch1, int& out_ch2)
It returns the respective output sample for the stereo input For a mono signal, set in_ch2 = 0
void Delete()
It releases buffer memory
void Reset()
void SetAttackSpeed(double db_per_second)
Low compression: 5 db/sec, Medium compression: 10 db/sec, High compression: 20 db/sec
void SetBitsResolution(int bitsResolution)
8, 16, 24
void SetReleaseSpeed(double db_per_second)
Low compression: 2 db/sec, Medium compression: 10 db/sec, High compression: 20 db/sec
void SetSamplesPerSec(int samplesPerSec)
22050, 44100, 48000, 96000, ...
~ AutomaticGainControl()
double ReleaseSpeed
double AttackSpeed
int BitsResolution
int SamplesPerSec

Bessel
static double I0(double x)
The first kind modified Bessel function of integer order 0, for any real x
static double I1(double x)
The first kind modified Bessel function of integer order 1, for any real x
static double In(int n, double x)
The first kind modified Bessel function of integer order n, for any real x
static double J0(double x)
The first kind Bessel function of integer order 0, for any real x
static double J1(double x)
The first kind Bessel function of integer order 1, for any real x
static double Jn(int n, double x)
The first kind Bessel function of integer order n, for any real x
~ Bessel(void)

BinaryConverter: It provides support to handle binary data
BinaryConverter(void)
bool GetBit(int bitIndex)
int Convert(int value)
static int Convert(const int value, const int bitCount, valarray<double >& output)
static int Convert(const int value, const int bitCount, valarray<int >& output)
~ BinaryConverter(void)

Chebyshev
static bool ComputeCoefficients_FirstKind(Math::IFunction& function, double a, double b, int N, valarray<double >& out_c)
Chebyshev Approximation coefficients in the interval [a b] A method for numerical integration on an automatic computer. C.W. Clenshaw and A. R. Curtis, Numerische Mathematik 1960
static bool ComputeCoefficients_SecondKind(Math::IFunction& function, double a, double b, int N, valarray<double >& out_c)
Chebyshev Approximation coefficients in the interval [a b] A method for numerical integration on an automatic computer. C.W. Clenshaw and A. R. Curtis, Numerische Mathematik 1960
static double ComputeApproximation_FirstKind(double a, double b, const double* in_c, const int size_of_c, double x)
a < x < b; f(x) = c_0/2 + SUM[c_n Tn(t)]; t = (2x - b - a)/(b - a); n goes from 1 to size_of_c-1
static double ComputeApproximation_FirstKind(double a, double b, const valarray<double >& in_c, int m, double x)
The only difference between ComputeApproximation_FirstKind and ComputeApproximation_SecondKind is that ComputeApproximation_SecondKind adds half of the last term in the approximation a < x < b; m is the degree of the approximation f(x) = c_0/2 + SUM[c_n Tn(t)]; t = (2x - b - a)/(b - a); n goes from 1 to m-1
static double ComputeApproximation_SecondKind(double a, double b, const valarray<double >& in_c, int m, double x)
The only difference between ComputeApproximation_FirstKindand ComputeApproximation_SecondKind is that ComputeApproximation_SecondKind adds half of the last term in the approximation a < x < b and m is the degree of the approximation
static double Tn(const unsigned int n, double x)
Polynomial of the first kind of integer order n
static double Un(const unsigned int n, double x)
Polynomial of the second kind of integer order n
~ Chebyshev(void)

Delay: It implements a signal delay
Delay(void)
bool SetDelay(int delay)
int ComputeOutput(int input)
void Reset()
~ Delay(void)

DiscreteCosineT: 8 points Discrete Cosine Transform
DiscreteCosineT()
void Inverse(float* buffer, bool scale, size_t stride)
stride can be 1 or 8
void Transform(float* buffer, bool scale, size_t stride)
stride can be 1 or 8
~ DiscreteCosineT()

Dsp: It provides a set of functions for Digital Signal Processing
static bool Convolution(const valarray<complex<double>>& input_x, const valarray<complex<double>>& input_y, valarray<complex<double>>& result)
static bool Convolution(const valarray<double >& input_x, const valarray<double >& input_y, valarray<double >& result)
static bool FourierTransform(const MATRIXC& input, MATRIXC& output, bool inverse)
static bool FourierTransform(const valarray<complex<double>>& input, valarray<complex<double>>& output, bool inverse)
static bool FourierTransformRe(const MATRIX& input, MATRIXC& output)
static bool FourierTransformRe(const valarray<double >& input, valarray<complex<double>>& output)
static bool HighPass(const valarray<double >& input, valarray<double >& output, double cutFreqRad)
static bool InverseFourierTransformRe(const MATRIXC& input, MATRIX& output)
static bool InverseFourierTransformRe(const valarray<complex<double>>& input, valarray<double >& output)
static bool IsPowerOfTwo(int input)
static bool LowPass(const valarray<double >& input, valarray<double >& output, double cutFreqRad)
static bool ShortConvolution(const valarray<complex<double>>& input_x, const valarray<complex<double>>& input_y, valarray<complex<double>>& result)
static bool ShortConvolution(const valarray<double >& input_x, const valarray<double >& input_y, valarray<double >& result)
static bool SpectrumFold(const valarray<complex<double>>& input, valarray<complex<double>>& output)
input: x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7] output: x[4], x[5], x[6], x[7], x[0], x[1], x[2], x[3]
static bool SpectrumFold(const valarray<double >& input, valarray<double >& output)
input: x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7] output: x[4], x[5], x[6], x[7], x[0], x[1], x[2], x[3]
static bool SpectrumUnfold(const valarray<complex<double>>& input, valarray<complex<double>>& output)
static bool SpectrumUnfold(const valarray<double >& input, valarray<double >& output)
static bool SymmetricConvolution(const valarray<complex<double>>& symmetricInput, const valarray<complex<double>>& input_y, valarray<complex<double>>& result)
static bool SymmetricConvolution(const valarray<complex<double>>& symmetricInput, const valarray<double >& input_y, valarray<complex<double>>& result)
static bool SymmetricConvolution(const valarray<double >& symmetricInput, const valarray<double >& input_y, valarray<double >& result)
static const wchar_t* Fft(MATRIXC& in_out, bool inverse)
static const wchar_t* Fft(const MATRIX& input, MATRIXC& output, bool inverse)
static const wchar_t* Fft(const MATRIXC& input, MATRIXC& output, bool inverse)
static const wchar_t* Fft(const valarray<complex<double>>& input, valarray<complex<double>>& output, bool inverse)
static const wchar_t* Fft(const valarray<double >& input, valarray<complex<double>>& output, bool inverse)
static const wchar_t* Fft(valarray<complex<double>>& in_out, bool inverse)
output[0] is the lowest frequency (offset) pi/m, 2pi/m, 3pi/m, ...pi,.....,2pi-3pi/m, 2pi-2pi/m, 2pi-pi/m Let m = input.size() Then output[m/2] is output[PI] And output[m-1] is output[2PI - PI/m] For real domain series output is conjugate symmetric, i.e., 10, 8+3j, 2+4j, 5-6j, 0, 5+6j, 2-4j, 8-3j
static const wchar_t* Fft2D(const MATRIX& input, MATRIXC& output)
static const wchar_t* Fft2D(const MATRIXC& input, MATRIXC& output)
static const wchar_t* IFft2D(bool isInputSymmetric, const MATRIXC& input, MATRIXC& output)
static const wchar_t* Periodogram(const valarray<complex<double>>& input, valarray<double >& output)
static const wchar_t* RealFft(MATRIX& in_out, bool inverse)
Real and Imaginary parts are stored sequencially
static const wchar_t* RealFft(const MATRIX& input, MATRIX& output, bool inverse)
Real and Imaginary parts are stored sequencially
static const wchar_t* RealFft(const valarray<double >& input, valarray<complex<double>>& output)
FFT optimized for real domain series, output is conjugate symmetric, i.e., 10, 8+3j, 2+4j, 5-6j, 0, 5+6j, 2-4j, 8-3j
static const wchar_t* RealFft(const valarray<double >& input, valarray<double >& output, bool inverse)
Real and Imaginary parts are stored sequencially
static const wchar_t* RealFft(valarray<double >& in_out, bool inverse)
Real and Imaginary parts are stored sequencially
static const wchar_t* Spectrum(const MATRIX& input, MATRIX& output)
static const wchar_t* Spectrum(const MATRIXC& input, MATRIX& output)
static const wchar_t* Spectrum(const valarray<complex<double>>& input, valarray<double >& output)
static const wchar_t* Spectrum(const valarray<double >& input, valarray<double >& output)
static const wchar_t* TwoFft(const valarray<double >& input1, const valarray<double >& input2, valarray<complex<double>>& out_fft1, valarray<complex<double>>& out_fft2)
static const wchar_t* TwoIfft(const valarray<complex<double>>& input_fft1, const valarray<complex<double>>& input_fft2, valarray<double >& output1, valarray<double >& output2)
static double AngleRotate(double x)
static double AngleRotate2(double x)
static double Circ(double x)
static double ComputeBeta(double stopBandGaindB)
static double Delta(double x)
static double Impulse(int n, int delay)
n is the discrete time d[n-delay]
static double Kaiser(double beta, double x)
static double Pi(int n, int delay, int duration)
static double Rect(double x)
static double Rectangular(double x, double period)
static double Sawtooth(double x, double period)
static double Sgn(double x)
static double Sin(int n, double k, int delay)
n is the discrete time Sin(kn-delay)
static double Sinc(double x)
static double Sinc(int n, double k, int delay)
n is the discrete time Sin(kn-delay)
static double Step(double x)
static double Step(int n, int delay)
n is the discrete time u[n-delay]
static double Triangular(double x, double period)
static int ComputeM(double stopBandGaindB, double transitionWidthRad)
static int FindNextPowerOfTwo(int input)
static int FindPreviousPowerOfTwo(int input)
static void Autocorrelation(const valarray<complex<double>>& input, valarray<complex<double>>& output)
static void Autocorrelation(const valarray<double >& input, valarray<double >& output)
static void Autocorrelation2(const valarray<complex<double>>& input, valarray<complex<double>>& output)
static void Autocorrelation2(const valarray<double >& input, valarray<double >& output)
static void FreqRespHighPass(double beta, int length, double cutFreqRad, valarray<double >& out_H)
static void FreqRespHilbertTransform(double beta, int length, valarray<double >& out_H)
static void FreqRespHilbertTransform(double sampFreqHz, double rippleErrordB, double transitionWidthHz, valarray<double >& out_H)
static void FreqRespLowPass(double beta, int length, double cutFreqRad, valarray<double >& out_H)
static void GetModulus(const valarray<complex<double>>& input, valarray<double >& output)
static void ImpulRespHighPass(double beta, int length, double cutFreqRad, valarray<double >& out_h)
static void ImpulRespHighPass(double sampFreqHz, double cutFreqHz, double stopBandGaindB, double transitionWidthHz, valarray<double >& out_h)
static void ImpulRespHilbertTransform(double beta, int length, valarray<double >& out_h)
static void ImpulRespHilbertTransform(double sampFreqHz, double rippleErrordB, double transitionWidthHz, valarray<double >& out_h)
static void ImpulRespLowPass(double beta, int length, double cutFreqRad, valarray<double >& out_h)
cutFreqRad is in radians cutFreqRad = 2 * pi * fc / fs;
static void ImpulRespLowPass(double sampFreqHz, double cutFreqHz, double stopBandGaindB, double transitionWidthHz, valarray<double >& out_h)
static void KaiserWindow(double beta, int length, valarray<double >& out_window)
static void PhaseNormalization(MATRIX& in_out)
static void PhaseNormalization(MATRIXC& in_out)
static void PhaseNormalization(valarray<complex<double>>& in_out)
static void PhaseNormalization(valarray<double >& in_out)
static void SpectrumFold(valarray<complex<double>>& in_out)
input: x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7] output: x[4], x[5], x[6], x[7], x[0], x[1], x[2], x[3]
static void SpectrumFold(valarray<double >& in_out)
input: x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7] output: x[4], x[5], x[6], x[7], x[0], x[1], x[2], x[3]
static void SpectrumUnfold(valarray<complex<double>>& in_out)
static void SpectrumUnfold(valarray<double >& in_out)
static void WelchWindow(int length, valarray<double >& out_window)
~ Dsp()

EigenSystem: It provides a set of functions to find the eigen-values and eigen-vectors
static const wchar_t* Jacobi(MATRIX& input, valarray<double >& eigen_value, MATRIX& eigen_vector)

FIRFilter: An finite impulse response filter
FIRFilter(void)
bool Create(valarray<double >& impulseResponse)
double GenerateOutput(double input)
virtual ~ FIRFilter(void)
void ClearTaps()

FIRFilter16: An finite impulse response filter of 16 bits
FIRFilter16(void)
__int16 GenerateOutput(__int16 input)
__int16 GenerateOutputAntisymmetric(__int16 input)
__int16 GenerateOutputSymmetric(__int16 input)
bool Create(valarray<double >& impulseResponse)
virtual ~ FIRFilter16(void)
void ClearTaps()

FindMinimum: It finds the minimum of a function of one variable, i.e. y = f(x)
FindMinimum(void)
static double BrentWithDerivative(Math::IFunctionD& func, const double a, const double b, const double c, const double tol, double& out_minX)
It computes the value of x that minimizes y = f(x) given the values of a, b and c returned by the funcion Bracketing() The function returns the y = f(x) and min_out_x where min_out_x is value of x that produces the minimum value of y
static double FindMinimum::Brent(Math::IFunction& func, const double a, const double b, const double c, const double tol, double& out_minX)
It computes the value of x that minimizes y = f(x) given the values of a, b and c returned by the funcion Bracketing() The function returns the y = f(x) and out_minX where out_minX is value of x that produces the minimum value of y
static void Bracketing(Math::IFunction& func, Math::Point& a, Math::Point& b, Math::Point& c)
Given a function y = f(x), and two distinct initial values of x: a and b Bracketing searches the downhill direction to return: - three values of x: a, b, c that bracket a minimum of the function - three values of y: ya = f(a), yb = f(b), and yc = f(c).

FindMinimumMV: It finds the minimum of a multivariable function, i.e. y = f(x0, x2, ..., xn) It requires the computation of: f(x0, x2, ..., xn) and its derivative
DWORD ThreadFunc(Mt::ThreadLink& threadLink)
FindMinimumMV()
bool Setup(Mt::DoubleTs& error, Math::IMultiVarFuncD& ifunc, const valarray<double >& startingPoint, int numIterations, double goal, int method)
method: WT_MATH_CONJGRAD, WT_MATH_VARMETRIC
double EvaluateFunc(const double x)
virtual ~ FindMinimumMV()
void EvaluateFuncAndDeriv(const double x, double& Fx, double& dFx)
void SetPostMessage(HWND hWnd, UINT wm_message, WPARAM wParam, LPARAM lParam)
It sets the information to call ::PostMessage when the ThreadFunc completes If hWnd is set to nullptr, ::PostMessage will not be called wm_message can be: WM_APP+1, WM_APP+2, WM_APP+3, ...

GaborTransform
GaborTransform()
bool Create(int delta_n, int numFreq)
bool Create(int numFreq)
bool Transform(const valarray<double >& input, MATRIXC& output)
double GetDeltaF()
double GetDeltaT()
double GetSigma()
~ GaborTransform()

Gamma
static double Function(double input)
It returns the value of the Gamma function
static double Ln(double input)
It returns the natural logarithm of the Gamma function
~ Gamma()

GeneticAlgorithm: It provides support to perform Genetic Algorithm Optimization
DWORD ThreadFunc(Mt::ThreadLink& threadLink)
GeneticAlgorithm()
bool Setup(Mt::DoubleTs& error, size_t bitsPerIndividual, Math::IGenetic& igenetic)
void Delete()
void ListIndividuals(HWND hWnd)
void SetPostMessage(HWND hWnd, UINT wm_message, WPARAM wParam, LPARAM lParam)
It sets the information to call ::PostMessage when the ThreadFunc completes If hWnd is set to nullptr, ::PostMessage will not be called wm_message can be: WM_APP+1, WM_APP+2, WM_APP+3, ...
~ GeneticAlgorithm()

GeneticIndividual: It represents one individual in a Genetic Algorithm Optimization
GeneticIndividual& operator =(const Math::GeneticIndividual& init)
GeneticIndividual()
GeneticIndividual(const Math::GeneticIndividual& init)
Math::GeneticIndividual operator Unrecognized character ^(const Math::GeneticIndividual& init)const
Math::GeneticIndividual operator |(const Math::GeneticIndividual& init)const
Math::GeneticIndividual operator&(const Math::GeneticIndividual& init)const
Math::GeneticIndividual& operator Unrecognized character ^ =(const Math::GeneticIndividual& init)
Math::GeneticIndividual& operator | =(const Math::GeneticIndividual& init)
Math::GeneticIndividual& operator& =(const Math::GeneticIndividual& init)
__int32 GetInt32(size_t index)const
bool AreAllOne() const
bool AreAllZero() const
bool AtLeastOneOne() const
bool AtLeastOneZero() const
bool CopyBits(const Math::GeneticIndividual& source, size_t indexStart, size_t indexEnd)
bool Create(size_t numBits)
bool CsvLoad(const wchar_t* filename)
bool CsvSave(const wchar_t* filename)const
bool GetBit(size_t bitIndex)const
bool operator !=(const Math::GeneticIndividual& init)const
bool operator <(const Math::GeneticIndividual& input)const
bool operator ==(const Math::GeneticIndividual& init)const
size_t GetActiveBitCount() const
size_t GetNumBits() const
void Copy(const Math::GeneticIndividual& init)
void Delete()
void FlipAllBits()
void FlipBit(size_t bitIndex)
void GetString(wchar_t* buffer, size_t bufferSize)const
void GetString(wstring& output)const
void SetAllToOne()
void SetAllToZero()
void SetBit(size_t bitIndex, bool value)
void SetInt32(size_t index, __int32 value)
void SetRandomBits(Sys::RandomFast& random)
void Show(HWND hWnd, const wchar_t* caption)const
~ GeneticIndividual()

GeneticParam
GeneticParam()
~ GeneticParam()

IFunction: A function of one variable double EvaluateFunc(const double x)
virtual double EvaluateFunc(const double x)= 0

IFunctionC: A function of one complex variable complex EvaluateFunc(const double x)
virtual complex<double>EvaluateFunc(const double x)= 0

IFunctionD: A function of one variable and its derivative double EvaluateFunc(const double x) void EvaluateFuncAndDeriv(const double x, double& Fx, double& dFx)
virtual void EvaluateFuncAndDeriv(const double x, double& Fx, double& dFx)= 0
The function must compute F(x) and dFx/dx

IGenetic: The general interface to use Genetic Algorithm Optimization
virtual double GeneticGetError() = 0
It returns the individual error in the range from 0 to 1
virtual void GeneticInitialize(Math::GeneticIndividual& individual)= 0
The individual bits must be set on this function to create the population
virtual void GeneticSetFromBits(const Math::GeneticIndividual& individual)= 0
It converts the bits of the individual to the specific variables of the problem

IMultiVarFunc: A function of several variables double EvaluateFunc(const valarray& x);
virtual double EvaluateFunc(const valarray<double >& x)= 0

IMultiVarFuncD: A function of several variables and its gradient double EvaluateFunc(const valarray& x); void EvaluateFuncAndGrad(const valarray& x, double& Fx, valarray& gradient);
virtual void EvaluateFuncAndGrad(const valarray<double >& x, double& Fx, valarray<double >& gradient)= 0
The function must compute F(x) and its gradient

ISimAnneal: The general interface to use Simulated Annealing Optimization
virtual double SimAnnealGetError() = 0
virtual void SimAnnealCopy(const Math::ISimAnneal& source)= 0
virtual void SimAnnealInitialize() = 0
virtual void SimAnnealPerturb(Math::ISimAnneal& original, double temperature, double initialTemperature)= 0

Interpolation: It provides a set of functions to interpolate a function of: one variable f(x) or two variables f(x, y)
static double Bilinear(const valarray<double >& vx, const valarray<double >& vy, const MATRIX& fxy, const double x, const double y)
The size of x must be equal to the number of rows of fxy The size of y must be equal to the number of columns of fxy x must contain a set of values for x. i.e., {0, 0.11, 0.2, 0.3, 0.4, 0.6} y must contain a set of values for y. i.e., {1, 2, 3, 4, 5} fxy must contain a set of values for f(x, y) The function returns the interpolation of f(x, y)
static double Lagrange(const MATRIX& x_fx, const double x)
The input matrix x_fx must have two columns: x and f(x) It returns the value of f(x) for the given value of x
static double Lagrange2D(const valarray<double >& vx, const valarray<double >& vy, const MATRIX& fxy, const double x, const double y)
The size of x must be equal to the number of rows of fxy The size of y must be equal to the number of columns of fxy x must contain a set of values for x. i.e., {0, 0.11, 0.2, 0.3, 0.4, 0.6} y must contain a set of values for y. i.e., {1, 2, 3, 4, 5} fxy must contain a set of values for f(x, y) The function returns the interpolation of f(x, y)
static double Linear(const MATRIX& x_fx, double& out_m, double& out_b)
It fits y = mx + b to the data given by the matrix x_fx, The x_fx matrix must have two columns: x and f(x) The function returns the value of chi-square to measure how well the line fits the data
static double Neville(const MATRIX& x_fx, const double x)
The input matrix x_fx must have two columns: x and f(x) It returns the value of f(x) for the given value of x
static double Neville(const MATRIX& x_fx, const double x, double& out_error)
The input matrix x_fx must have two columns: x and f(x) It returns the value of f(x) for the given value of x It also returns the error
static double Neville2D(const valarray<double >& vx, const valarray<double >& vy, const MATRIX& fxy, const double x, const double y)
The size of x must be equal to the number of rows of fxy The size of y must be equal to the number of columns of fxy x must contain a set of values for x. i.e., {0, 0.11, 0.2, 0.3, 0.4, 0.6} y must contain a set of values for y. i.e., {1, 2, 3, 4, 5} fxy must contain a set of values for f(x, y) The function returns the interpolation of f(x, y)
~ Interpolation()

KMeans: It implements the clustering algorithm K-means
KMeans()
void CreateClusters(size_t iterationCount, const MATRIX& input, size_t K, MATRIX& out_centroid, vector<int >& out_cluster)
The function groups the rows in 'input' to create K clusters. The resulting centroid of the K clusters are returned in out_centroid The resulting cluster index for each input (0, 1, 2, ..., K-1) is returned in out_cluster
~ KMeans()

Normalization: It normalizes a vector so that the mean is zero and the standard deviation is one
Normalization()
void poststd(valarray<double >& values)
void prestd(valarray<double >& values)
~ Normalization()

NumericDerivative: It provides a set of functions to estimate the numeric value of the derivative of a function y = f(x) Finite forward differences are used to estimate the derivative of the first points in the array. Finite backward differences are used to estimate the derivative of the last points in the array. Finite central differences are used to estimate the derivative in the rest points in the array.
static void FirstDerivative(double deltaX, const valarray<double >& in_y, valarray<double >& out_dy)
static void SecondDerivative(double deltaX, const valarray<double >& in_y, valarray<double >& out_dy)
static void ThirdDerivative(double deltaX, const valarray<double >& in_y, valarray<double >& out_dy)
virtual ~ NumericDerivative(void)

NumericIntegration: It provides a set of functions to perform numeric integration
static complex<double>Simpson(Math::IFunctionC& function, double a, double b, double& resultingError)
static complex<double>Simpson(Math::IFunctionC& function, double a, double b, int steps, double& resultingError)
static double AdaptiveSimpson(Math::IFunction& function, double a, double b, double errorTolerance, int maxRecursionDepth)
maxRecursionDepth = 100; errorTolerance = 1.0e-7
static double ClenshawCurtis(Math::IFunction& function, double a, double b)
static double ClenshawCurtis(Math::IFunction& function, double a, double b, int N)
static double Simpson(Math::IFunction& function, double a, double b, double& resultingError)
static double Simpson(Math::IFunction& function, double a, double b, int steps, double& resultingError)
steps will be approximated to next multiple of 4
static double Simpson3_8(Math::IFunction& function, double a, double b, int steps)
steps will be approximated to next multiple of 3
virtual ~ NumericIntegration(void)

Oper: A set of functions to perform Math, Vector and Matrix operations
Oper()
static bool AppendDown(MATRIX& in_out, const MATRIX& in_B)
static bool AppendDown(MATRIXC& in_out, const MATRIXC& in_B)
static bool AppendRight(MATRIX& in_out, const MATRIX& in_B)
static bool AppendRight(MATRIXC& in_out, const MATRIXC& in_B)
static bool AreTheyEqual(const MATRIX& a, const MATRIX& b)
static bool AreTheyEqual(const MATRIXC& a, const MATRIXC& b)
static bool ComputeRelativeError(const MATRIX& measuredValue, const MATRIX& expectedValue, valarray<double >& out_relError)
Returns a vector with the relative error values for each case (rows)
static bool CopyColToClipboard(HWND hWnd, const MATRIX& input, int col_index)
static bool CopyMatrix(const MATRIX& source, MATRIX& destination)
static bool CopyRowToClipboard(HWND hWnd, const MATRIX& input, int row_index)
static bool CopyToClipboard(HWND hWnd, const MATRIX& input)
static bool CreateMatrix(MATRIX& in_out, size_t rowCount, size_t colCount)
static bool CreateMatrix(MATRIXC& in_out, size_t rowCount, size_t colCount)
static bool CreateRandom(MATRIX& in_out, int rowCount, int colCount, double minValue, double maxValue)
static bool CreateRandom(valarray<double >& in_out, int length, double minValue, double maxValue)
static bool CreateRandomSet(valarray<double >& in_out, int length, int maxValue)
static bool DeleteCell(valarray<complex<double>>& in_out, int index)
static bool DeleteCell(valarray<double >& in_out, int index)
static bool DeleteCol(MATRIX& in_out, int colIndex)
static bool DeleteCol(MATRIXC& in_out, int colIndex)
static bool DeleteCols(MATRIX& input, const valarray<size_t>indexes)
static bool DeleteCols(MATRIXC& input, const valarray<size_t>indexes)
static bool DeleteCols(const MATRIX& input, MATRIX& output, const valarray<size_t>indexes)
static bool DeleteCols(const MATRIXC& input, MATRIXC& output, const valarray<size_t>indexes)
static bool DeleteRow(MATRIX& in_out, int rowIndex)
static bool DeleteRow(MATRIXC& in_out, int rowIndex)
static bool DeleteRows(MATRIX& input, const valarray<size_t>indexes)
static bool DeleteRows(MATRIXC& input, const valarray<size_t>indexes)
static bool DeleteRows(const MATRIX& input, MATRIX& output, const valarray<size_t>indexes)
static bool DeleteRows(const MATRIXC& input, MATRIXC& output, const valarray<size_t>indexes)
static bool GetCol(const MATRIX& input, MATRIX& output, int index)
static bool GetCol(const MATRIX& input, valarray<double >& output, int index)
static bool GetCol(const MATRIXC& input, MATRIXC& output, int index)
static bool GetCol(const MATRIXC& input, valarray<complex<double>>& output, int index)
static bool GetCols(const MATRIX& input, MATRIX& output, const valarray<size_t>indexes)
static bool GetCols(const MATRIXC& input, MATRIXC& output, const valarray<size_t>indexes)
static bool GetMinMax(const MATRIX& input, double& out_min, double& out_max)
static bool GetMinMax(const MATRIXC& input, double& out_min, double& out_max)
static bool GetRow(const MATRIX& input, MATRIX& output, int index)
static bool GetRow(const MATRIX& input, valarray<double >& output, int index)
static bool GetRow(const MATRIXC& input, MATRIXC& output, int index)
static bool GetRow(const MATRIXC& input, valarray<complex<double>>& output, int index)
static bool GetRows(const MATRIX& input, MATRIX& output, const valarray<size_t>indexes)
static bool GetRows(const MATRIXC& input, MATRIXC& output, const valarray<size_t>indexes)
static bool InsertCell(valarray<complex<double>>& in_out, int index)
static bool InsertCell(valarray<double >& in_out, int index)
static bool InsertCol(MATRIX& in_out, int colIndex)
static bool InsertCol(MATRIXC& in_out, int colIndex)
static bool InsertRow(MATRIX& in_out, int rowIndex)
static bool InsertRow(MATRIXC& in_out, int rowIndex)
static bool IsPrime(int x)
static bool Transpose(const MATRIX& input, MATRIX& output)
static bool Transpose(const MATRIXC& input, MATRIXC& output)
static bool WrapVector(const valarray<complex<double>>& input, int colCount, MATRIXC& output)
static bool WrapVector(const valarray<double >& input, int colCount, MATRIX& output)
static const wchar_t* ConfusionMatrix(const MATRIX& output, const MATRIX& target, double threshold, MATRIX& out_confusionMatrix)
It computes the confusion matrix for classification, for SoftMax set threshold to 0.0, otherwise set to 0.5
static const wchar_t* ConfusionMatrix(const MATRIXC& output, const MATRIXC& target, double threshold, MATRIX& out_confusionMatrix)
static const wchar_t* GetClass(const MATRIX input, valarray<double >& classes, double threshold)
static const wchar_t* GetClass(const MATRIX input, valarray<int >& classes, double threshold)
static const wchar_t* GetClass(const MATRIXC input, valarray<double >& classes, double threshold)
static const wchar_t* Product(const MATRIX& input_a, const MATRIX& input_b, MATRIX& output)
static const wchar_t* Product(const MATRIX& input_a, const valarray<double >& input_b, MATRIX& output)
static const wchar_t* Product(const MATRIX& input_a, const valarray<double >& input_b, valarray<double >& output)
static const wchar_t* Product(const MATRIXC& input_a, const MATRIXC& input_b, MATRIXC& output)
static const wchar_t* Product(const MATRIXC& input_a, const valarray<complex<double>>& input_b, valarray<complex<double>>& output)
static const wchar_t* Product(const valarray<complex<double>>& input_a, const MATRIXC& input_b, int rowb_index, MATRIXC& output)
static const wchar_t* Product(const valarray<double >& input_a, const MATRIX& input_b, int rowb_index, MATRIX& output)
static double ArcTangent(double y, double x)
It returns an angle from 0 to 2pi ArcTangent(1, 1) = 0.785398 radians (45 degrees) ArcTangent(1, -1) = 2.35619 radians (135 degrees) ArcTangent(-1, -1) = 3.9270 radians (225 degrees) ArcTangent(-1, 1) = 5.4978 radians (315 degrees)
static double ComputeDistance(const valarray<double >& x, const valarray<double >& y)
static double ComputeMse(const MATRIX& input_a, const MATRIX& input_b)
returns 9.99e300 if error
static double ComputeMse(const valarray<double >& input_a, const valarray<double >& input_b)
returns 9.99e300 if error
static double ComputeRelativeError(const MATRIX& measuredValue, const MATRIX& expectedValue)
returns 9.99e300 if error
static double DotProduct(const size_t len, const double* a, const double* b)
static double DotProduct(const size_t len, const valarray<double >& a, const valarray<double >& b)
static double DotProduct(const valarray<double >& a, const valarray<double >& b)
static double Factorial(unsigned int x)
static double GetMaximum(const MATRIX& input)
static double GetMinimum(const MATRIX& input)
static double LineFitting(const valarray<double >& in_x, const valarray<double >& in_y, double& out_m, double& out_b)
Given a set of points (x, y) it returns the value of m and b so that y = mx+b The function returns the mean squared error
static double Round(double value, int decimalCount)
static double Round05(double value)
Round05(9.2) returns 9.0 Round05(9.45) return 9.5 Round05(9.62) returns 9.5 Round05(9.78) return 10.0
static double Sign(const double& a, const double& b)
static int GetClass(const valarray<complex<double>>& inputRow, double threshold)
static int GetClass(const valarray<double >& inputRow, double threshold)
static void AddValue(MATRIX& in_out, double value)
static void Denavit(double theta, double alpha, double r, double d, MATRIX& output)
alpha and theta must be in radians cos(theta) -cos(alpha)*sin(theta) sin(alpha)*sin(theta) r*cos(theta) sin(theta) cos(alpha)*cos(theta) -sin(alpha)*cos(theta) r*sin(theta) 0 sin(alpha) cos(alpha) d 0 0 0 1
static void DenavitD(double theta, double alpha, double r, double d, MATRIX& output)
alpha and theta must be in degrees cos(theta) -cos(alpha)*sin(theta) sin(alpha)*sin(theta) r*cos(theta) sin(theta) cos(alpha)*cos(theta) -sin(alpha)*cos(theta) r*sin(theta) 0 sin(alpha) cos(alpha) d 0 0 0 1
static void DivideBy(MATRIX& in_out, double value)
static void MultiplyBy(MATRIX& in_out, double value)
static void Normalize(valarray<double >& in_out)
It rescales the data to zero mean and unit variance
static void Normalize(valarray<double >& in_out, double minimum, double maximum)
It rescales the data to the range [0 1]
static void NormalizeCols(MATRIX& in_out)
It rescales the data to zero mean and unit variance
static void NormalizeCols(MATRIX& in_out, double minimum, double maximum)
It rescales the data to the range [0 1]
static void NormalizeRows(MATRIX& in_out)
It rescales the data to zero mean and unit variance
static void NormalizeRows(MATRIX& in_out, double minimum, double maximum)
It rescales the data to the range [0 1]
static void SetMatrix(MATRIX& in_out, double value)
static void SetTo(valarray<double >& in_out, double value)

PidController: It implements a proportional integral derivative controller
PidController(void)
double Create(double kp, double ki, double kd, double targetValue, double minControlValue, double maxControlValue)
double GetControlValue(double measuredValue)
double GetControlValue(double measuredValue, double amortiguamiento)
~ PidController(void)

PowellFindMinMV: It finds the minimum of a multivariable function, i.e. y = f(x0, x2, ..., xn) This function is set when calling Setup(error, *this, startingPoint, 200) It requires only the computation of: f(x0, x2, ..., xn)
DWORD ThreadFunc(Mt::ThreadLink& threadLink)
PowellFindMinMV()
bool Setup(Mt::DoubleTs& error, Math::IMultiVarFunc& ifunc, const valarray<double >& startingPoint, int numIterations)
virtual ~ PowellFindMinMV()
void Delete()
You may call to this function to release memory, but you dont have to
void SetPostMessage(HWND hWnd, UINT wm_message, WPARAM wParam, LPARAM lParam)
It sets the information to call ::PostMessage when the ThreadFunc completes If hWnd is set to nullptr, ::PostMessage will not be called wm_message can be: WM_APP+1, WM_APP+2, WM_APP+3, ...

Remez: Filter Design: Low Pass, High Pass, Band Passs, Hilbert, Differentiator Given a set of bands, it computes the Finite Impulse Response of a filter: h[n].
static double ComputeDifferentiatorImpulseResponse(int length, valarray<double >& out_impulseResponse)
static double ComputeHilbertImpulseResponse(int length, valarray<double >& out_impulseResponse)
static double ComputeImpulseResponse(const vector<Math::Remez::Band >& in_band, int length, valarray<double >& out_impulseResponse)
~ Remez()

SimAnnealParam
SimAnnealParam()
~ SimAnnealParam()

SimulatedAnnealing: It provides support to perform Simulated Annealing Optimization
DWORD ThreadFunc(Mt::ThreadLink& threadLink)
SimulatedAnnealing()
void GetSimulationParameters(Math::SimAnnealParam& out_param)
void SetPostMessage(HWND hWnd, UINT wm_message, WPARAM wParam, LPARAM lParam)
It sets the information to call ::PostMessage when the ThreadFunc completes If hWnd is set to nullptr, ::PostMessage will not be called wm_message can be: WM_APP+1, WM_APP+2, WM_APP+3, ...
void SetSimulationParameters(const Math::SimAnnealParam& in_param)
void Setup(Mt::DoubleTs& error, ISimAnneal& solution, ISimAnneal& work1, ISimAnneal& work2)
~ SimulatedAnnealing()

SingValDecompos: It performs a singular value decomposition, it can be used to solve a system of linear equations
static bool BackSubstitution(const MATRIX& u, const valarray<double >& s, const MATRIX& v, const valarray<double >& b, valarray<double >& x)
Solves A·x = b for a vector x where A is specified by U S V from a singular value descomposition U[m n], s[n], V[n n] b[m], x[n] 1. Call Decompose to produce S, U, V. Matrix U is return in variable a 2. Call BackSubstitution providing S, U, V as returned by Decompose Returns false if not enough memory
static const wchar_t* Decompose(MATRIX& in_out_a, valarray<double >& out_s, MATRIX& out_v)
valarray s, x; MATRIX v; Math::SingValDecompos::Decompose(a, s, v); Math::SingValDecompos::BackSubstitution(a, s, v, b, x);
static const wchar_t* Decompose(const MATRIX& in_a, MATRIX& out_u, valarray<double >& out_s, MATRIX& out_v)
valarray s, x; MATRIX v; Math::SingValDecompos::Decompose(a, s, v); Math::SingValDecompos::BackSubstitution(a, s, v, b, x);
~ SingValDecompos()

SplineInterpolation: It interpolates a value for f(x) given a value of x and a table with the values of: x and f(x)
SplineInterpolation()
bool Create(const valarray<double >& x, const valarray<double >& fx)
i.e. x: 0, 2, 5, 10, 20 y: f(0), f(2), f(5), f(10), f(20)
double Interpolate(const double x)
~ SplineInterpolation()

SplineInterpolation2D: It interpolates a value for f(x, y) given a value of x, y and a table with the values of: x, y and f(x, y)
SplineInterpolation2D()
bool Create(const valarray<double >& x, const valarray<double >& y, const MATRIX& fxy)
The size of x must be equal to the number of rows of fxy The size of y must be equal to the number of columns of fxy x must contain a set of values for x. i.e., {0, 0.11, 0.2, 0.3, 0.4, 0.6} y must contain a set of values for y. i.e., {1, 2, 3, 4, 5} fxy must contain a set of values for f(x, y)
double Interpolate(const double x, const double y)
The function returns the interpolation of f(x, y)
~ SplineInterpolation2D()

Statistics: It provides a set of functions in Statistics
static bool MovingAverage(const valarray<double >& input, const int windowLength, valarray<double >& output)
static bool MovingAverageAndVariance(const valarray<double >& input, const int windowLength, valarray<double >& out_average, valarray<double >& out_variance)
static bool MovingVariance(const valarray<double >& input, const int windowLength, valarray<double >& output)
static complex<double>GetDiagonalSum(MATRIXC& input)
static complex<double>GetMagnitudeMax(MATRIXC& input, int& row, int& col)
static complex<double>GetMagnitudeMax(valarray<complex<double>>& input, int& position)
static complex<double>GetMagnitudeMin(MATRIXC& input, int& row, int& col)
static complex<double>GetMagnitudeMin(valarray<complex<double>>& input, int& position)
static complex<double>GetSum(MATRIXC& input)
static complex<double>GetSum(valarray<complex<double>>& input)
static complex<double>MeanValue(MATRIXC& input)
static complex<double>MeanValue(valarray<complex<double>>& input)
static complex<double>Variance(const MATRIXC& input)
static complex<double>Variance(const valarray<complex<double>>& input)
static const wchar_t* CorrelationMatrix(const MATRIX& input, MATRIX& output)
static const wchar_t* CovarianceMatrix(const MATRIX& input, MATRIX& output)
static double AbsoluteRelativeError(const valarray<double >& exact, const valarray<double >& approx)
static double Bias(valarray<double >& approx, double exact)
static double Bias(valarray<double >& exact, valarray<double >& approx)
static double Correlation(const valarray<double >& input_x, const valarray<double >& input_y)
static double CorrelationCoeff(const valarray<double >& input_x, const valarray<double >& input_y)
static double Covariance(const valarray<double >& input_x, const valarray<double >& input_y, bool bNormalDistr)
static double GetDiagonalSum(MATRIX& input)
static double GetMaximum(const MATRIX& input, int& row, int& col)
static double GetMaximum(const MATRIXC& input, int& row, int& col)
static double GetMaximum(const valarray<complex<double>>& input, int& position)
static double GetMaximum(const valarray<double >& input, int& position)
static double GetMinimum(const MATRIX& input, int& row, int& col)
static double GetMinimum(const MATRIXC& input, int& row, int& col)
static double GetMinimum(const valarray<complex<double>>& input, int& position)
static double GetMinimum(const valarray<double >& input, int& position)
static double GetSum(MATRIX& input)
static double GetSum(valarray<double >& input)
static double GetSumOfSquares(MATRIX& input)
static double GetSumOfSquares(MATRIXC& input)
static double GetSumOfSquares(valarray<complex<double>>& input)
static double GetSumOfSquares(valarray<double >& input)
static double MeanAbsoluteError(const valarray<double >& exact, const valarray<double >& approx)
static double MeanSquaredError(const valarray<double >& exact, const valarray<double >& approx)
static double MeanValue(MATRIX& input)
static double MeanValue(valarray<double >& input)
static double RelativeRootMeanSquareError(const valarray<double >& exact, const valarray<double >& approx)
static double RootMeanSquaredError(const valarray<double >& exact, const valarray<double >& approx)
static double StandardDeviation(const valarray<double >& input)
static double TheilIndex(valarray<double >& input)
static double TheilUInequalityIndex(valarray<double >& input_x, valarray<double >& input_y)
static double Variance(const MATRIX& input)
static double Variance(const valarray<double >& input)
static unsigned int Combinations(unsigned int n, unsigned int k)
static void AbsoluteRelativeError(const valarray<double >& exact, const valarray<double >& approx, valarray<double >& outRelativeError)
static void ColumnMaximum(const MATRIX& input, valarray<double >& output)
static void ColumnMean(const MATRIX& input, valarray<double >& output)
static void ColumnMinimum(const MATRIX& input, valarray<double >& output)
static void ColumnVariance(const MATRIX& input, valarray<double >& output)
static void RowMaximum(const MATRIX& input, valarray<double >& output)
static void RowMean(const MATRIX& input, valarray<double >& output)
static void RowMinimum(const MATRIX& input, valarray<double >& output)
static void RowVariance(const MATRIX& input, valarray<double >& output)
virtual ~ Statistics(void)

SyntheticDiv: It provides a set of functions to perform a synthetic division
static complex<double>Run(const valarray<complex<double>>& inputCoeff, valarray<complex<double>>& outputCoeff, complex<double>x)
static complex<double>Run(const valarray<complex<double>>& inputCoeff, valarray<complex<double>>& outputCoeff, complex<double>x, complex<double >& out_dx)
static double Newton(const valarray<complex<double>>& inputCoeff, valarray<complex<double>>& outputCoeff, complex<double >& int_out_x)
static double Newton(const valarray<double >& inputCoeff, valarray<double >& outputCoeff, double& int_out_x)
static double Run(const valarray<double >& inputCoeff, valarray<double >& outputCoeff, double x)
static double Run(const valarray<double >& inputCoeff, valarray<double >& outputCoeff, double x, double& out_dx)
virtual ~ SyntheticDiv(void)

TimeDependentFT: Time-dependent Fourier Transform
TimeDependentFT()
bool Create(int windowWidth, int numFrequencies, double beta)
bool Transform(const valarray<double >& input, MATRIXC& output)
~ TimeDependentFT()

TimePredictor: It estimates how long it will take for a task to complete
TimePredictor(void)
int GetPredictionInSeconds(double targetValue)
void AddValue(double value)
void Reset(void)
~ TimePredictor(void)

Trender: It eliminates trends in the data using a line: y = mx + b
Trender()
void CalculateMB(bool bLeastSquares, valarray<double >& source)
void posttrending(valarray<double >& source, valarray<double >& destination)
void pretrending(bool leastSquares, valarray<double >& source, valarray<double >& destination)
~ Trender()
© Copyright 2000-2021 selo. All Rights Reserved. Jul 22 2021.